package spring.calculator;

/**
 * @author Yancy xiao
 * @create 2022-11-19 15:50
 */
public class CalculatorStaticProxy implements Calculator {

    private CalulatorImpl target;//目标类

    public CalculatorStaticProxy(CalulatorImpl target) {
        this.target = target;
    }

    public CalculatorStaticProxy() {

    }

    @Override
    public int add(int i, int j) {
        System.out.println("日志，方法：add，参数：" + i + "," + j);
        int s = target.add(i, j);
        System.out.println("日志，方法：add，结果：" + i + "," + j);
        return s;
    }

    @Override
    public int sub(int i, int j) {
        System.out.println("日志，方法：sub，参数：" + i + "," + j);
        int s = target.sub(i, j);
        System.out.println("日志，方法：sub，结果：" + i + "," + j);
        return s;
    }

    @Override
    public int mul(int i, int j) {
        System.out.println("日志，方法：mul，参数：" + i + "," + j);
        int s = target.mul(i, j);
        System.out.println("日志，方法：mul，结果：" + i + "," + j);
        return s;
    }

    @Override
    public int div(int i, int j) {
        System.out.println("日志，方法：div，参数：" + i + "," + j);
        int s = target.div(i, j);
        System.out.println("日志，方法：div，结果：" + i + "," + j);
        return s;
    }
}
